home *** CD-ROM | disk | FTP | other *** search
- class Jewel extends MovieClip
- {
- static var MAXIMUM_FALLING_SPEED = 40;
- var mType = 0;
- var mIsDying = false;
- var mIsDead = false;
- var mOrigY = 0;
- var mTargetX = 0;
- var mTargetY = 0;
- var mIsFalling = false;
- var mIsMoving = false;
- var mYSpeed = 0;
- function Jewel()
- {
- super();
- }
- function setType(t)
- {
- this.mType = t;
- }
- function getType()
- {
- return this.mType;
- }
- function die()
- {
- if(!this.mIsDying)
- {
- this._parent._parent._parent.mDestroyedPieces = this._parent._parent._parent.mDestroyedPieces + 1;
- this.gotoAndPlay("boom");
- }
- this.mIsDying = true;
- }
- function isDying()
- {
- return this.mIsDying;
- }
- function isDead()
- {
- return this.mIsDead;
- }
- function isFalling()
- {
- return this.mIsFalling;
- }
- function isMoving()
- {
- return this.mIsMoving;
- }
- function fall(x, y)
- {
- this.mOrigY = this._y;
- this._y = this._y + 1;
- this.mIsFalling = true;
- this.mTargetX = x;
- this.mTargetY = y;
- }
- function move(x, y)
- {
- this.mIsMoving = true;
- this.mTargetX = x;
- this.mTargetY = y;
- }
- function onEnterFrame()
- {
- if(this.mIsFalling)
- {
- this.mYSpeed = (this._y - this.mOrigY) * 2;
- if(this.mYSpeed > Jewel.MAXIMUM_FALLING_SPEED)
- {
- this.mYSpeed = Jewel.MAXIMUM_FALLING_SPEED;
- }
- this._y += this.mYSpeed;
- if(this._y > this.mTargetY)
- {
- this._y = this.mTargetY;
- this.mIsFalling = false;
- }
- }
- else if(this.mIsMoving)
- {
- this._x += (this.mTargetX - this._x) / 3;
- this._y += (this.mTargetY - this._y) / 3;
- if(Math.abs(this.mTargetX - this._x) < 1 && Math.abs(this.mTargetY - this._y) < 1)
- {
- this.mIsMoving = false;
- this._x = this.mTargetX;
- this._y = this.mTargetY;
- }
- }
- }
- }
-